package com.ybwh.springboot2.activiti;

import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration;

public class InitTable {
	public static void main(String[] args) {
		ProcessEngine engine = init2();

		// 流程定义和部署 act_re_* 表
		RepositoryService repositoryService = engine.getRepositoryService();
		// 流程的运行 act_ru_*表
		RuntimeService runtimeService = engine.getRuntimeService();
		// 运行任务 act_ru_task
		TaskService taskService = engine.getTaskService();
		// 查询流程历史记录 act_hi_* 表
		HistoryService historyService = engine.getHistoryService();
		// 页面表单
		FormService formService = engine.getFormService();
		// 工作流用户管理 act_id_* 表
		IdentityService identityService = engine.getIdentityService();
		//
		ManagementService managementService = engine.getManagementService();

		// 流程定义 act_re_procdef
//        ProcessDefinition
		// 流程实例 act_hi_procinst
//        ProcessInstance

		// 执行中的分支路径 act_ru_execution
//        Execution

		// 任务实例 act_ru_task
//        TaskInfo

	}

	public static ProcessEngine init2() {
    	StandaloneProcessEngineConfiguration configuration =
                (StandaloneProcessEngineConfiguration)ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("/activiti.cfg.xml");
    	//设置 事务管理器,使得业务代码和流程代码处于同一事务中
//        configuration.setTransactionFactory();

        ProcessEngine engine = configuration.buildProcessEngine();
        System.out.println(engine);


        return engine;

    }

	public static void init1() {
		ProcessEngineConfiguration configuration = ProcessEngineConfiguration
				.createStandaloneProcessEngineConfiguration();

		configuration.setJdbcDriver("com.mysql.jdbc.Driver");
		configuration.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/activiti522");
		configuration.setJdbcUsername("root");
		configuration.setJdbcPassword("fan1988");
		configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    	//设置 事务管理器,使得业务代码和流程代码处于同一事务中
//      configuration.setTransactionFactory();

		ProcessEngine engine = configuration.buildProcessEngine();
		System.out.println(engine);
	}
}
